using System;
using System.Data;
using System.Collections.Generic;

namespace shfa.snomtastic.data.business
{
    public partial class EventLogController
    {
		private EventLogInfo ObjectFromDataRow(DataRow dr)
        {
            if (dr != null)
            {
				EventLogInfo obj = new EventLogInfo();
				obj.EventLogId = dr.Field<Guid>("EventLogId"); 
				obj.PhoneId = (dr["PhoneId"] != DBNull.Value) ? dr.Field<Guid>("PhoneId") : Guid.Empty; 
				obj.UserId = (dr["UserId"] != DBNull.Value) ? dr.Field<Guid>("UserId") : Guid.Empty; 
				obj.MacAddress = dr.Field<String>("MacAddress"); 
				obj.IpAddress = dr.Field<String>("IpAddress"); 
				obj.UserAgent = dr.Field<String>("UserAgent"); 
				obj.EventSource = dr.Field<String>("EventSource"); 
				obj.EventMessage = dr.Field<String>("EventMessage"); 
				obj.EventType = dr.Field<String>("EventType"); 
				obj.EventDate = dr.Field<DateTime>("EventDate"); 
				return obj;
            }
            return null;
        }

        private List<EventLogInfo> ListFromDataTable(DataTable dt)
        {
            List<EventLogInfo> lst = new List<EventLogInfo>();

            foreach (DataRow dr in dt.Rows)
            {
                lst.Add(ObjectFromDataRow(dr));
            }

            return lst;
        }
    }
}
